const mysql = require("mysql2/promise")//导入 链接数据库的库
const pool = mysql.createPool({
    host: "8.138.152.233",//数据库的ip地址
    user: "root",//账号
    password: "1514531680@qq.com",//密码
    database: "melody-chat",//要链接数据库的表名
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0
})

// 测试连接
pool.query("select 1")
    .then(() => console.log("数据库连接成功"))
    .catch(err => console.error("数据库连接失败:", err))

module.exports = pool;
